define (require, exports, module) ->
  # 引入样式
  require 'mods/zdymk_detail/zdymk_detail_css.css'
  # 引入API服务
  zdymk_detail_api = require "mods/zdymk_detail/zdymk_detail_api"

  module.exports = Vue.extend

    # 组件模板
    template: require 'mods/zdymk_detail/zdymk_detail_tpl.js'

    # 定义变量
    data: () ->
      # 是否加载完成
      loadedSucc: false
      # 加载失败提示语
      loadedFail: ''
      # 首页自定义模块menu数组
      zdymkNavs: [
        {'name':'公司简介'}
        {'name':'团队介绍'}
        {'name':'投资理念'}
      ]
      # 当前导航,改变菜单样式
      curNav: 0
      # 首页自定义模块数组
      custom_mk_arr: []
      # 模块的数据
      first_mk_obj: {}
      sec_mk_obj: {}
      third_mk_obj: {}
      # 显示当前那个模块的文本状态
      mk_statu: 1
      index: -1

    # 定义方法
    methods:

      # 切换首页自定义模块侧栏
      checkNav: (index) ->
        self = @
        self.curNav = index

        # 切换详情页数据
        if 0 is index
          self.mk_statu = 1
        if 1 is index
          self.mk_statu = 2
        if 2 is index
          self.mk_statu = 3

      # 获取首页自定义模块
      getZdymkList: () ->
        self = @
        params =
          pageNum: 1
          pageSize: 10

        # 获取模块数据
        return zdymk_detail_api.getZdymkList params
          .then (res) ->
            self.custom_mk_arr = res?.body?.data

            # 获取各模块的内容
            if !! self.custom_mk_arr
              for item in self.custom_mk_arr
                if "1" is '' + item?.mk
                  self.first_mk_obj = item
                if "2" is '' + item?.mk
                  self.sec_mk_obj = item
                if "3" is '' + item?.mk
                  self.third_mk_obj = item

            # 获取首页传过来的type，切换侧栏的状态
            if !! self.$route.params.type
              type = self.$route.params.type
              self.curNav = type
              if 0 is type
                self.mk_statu = 1
              if 1 is type
                self.mk_statu = 2
              if 2 is type
                self.mk_statu = 3

      # 插件加载
      pluginLoad: () ->
        self = @

      # 加载成功
      loadedSuccFunc: () ->
        self = @
        self.$nextTick () ->
          # 加载成功标识
          self.loadedSucc = true
          # 插件加载
          self.pluginLoad()

    # 计算属性
    computed:

      # 加载中的样式
      loaddingClass: () ->
        self = @
        if self.loadedSucc
          return 'c-hidden'
        if self.loadedFail
          return 'c-hidden'
        return ''

      # 加载成功的样式
      loadedSuccClass: () ->
        self = @
        return if self.loadedSucc then '' else 'c-vhidden'

      # 加载失败的样式
      loadedFailClass: () ->
        self = @
        return if self.loadedFail then '' else 'c-hidden'

    # 组件初始化执行
    mounted: () ->
      self = @

      # 获取首页模块自定义详情
      self.getZdymkList()

      # 加载成功 - 处理函数
      return self.loadedSuccFunc()